#include<bits/stdc++.h>
using namespace std;
const int M = 25;
int n, r, a[M], num;


/**
 * 
 * NOIP2000 进制转换
 */
int main(){
	scanf("%d %d", &n, &r);
	printf("%d=", n);
	while(n){
		a[++num] = n % r;
		if(n % r < 0){
			n += r;
			a[num] -= r;
		}
		n /= r;
	}
	for(int i = num; i >= 1; i--){
		if(a[i] < 10) printf("%d", a[i]);
		else printf("%c", a[i] - 10 + 'A');
	}
	printf("(base%d)", r);
	return 0;
}